﻿

using System;
using System.Drawing;

namespace _11_自定义控件
{
    /// <summary>
    /// 用户自定义的轨迹
    /// </summary>
    [Serializable]//可序列化声明(允许此类创建出来的对象从内存条保存到硬盘上)
    public class CustomPathShape : Shape
    {
        public CustomPathShape(string name, Color color) : base(name, color)
        {
        }
        /// <summary>
        /// 绘制形状
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            if (TrajectoryPoint.Count>1)
            {
                //绘制所有坐标点
                g.DrawLines(new Pen(Color, 2), TrajectoryPoint.ToArray());
            }
             
        }

        /// <summary>
        /// 更新坐标-更新坐标点
        /// </summary>
        /// <param name="currentPoint"></param>
        public override void Upadate(Point currentPoint)
        {
            TrajectoryPoint.Add(currentPoint);
        }
    }
}
